<template>

  <div id="app">
    <van-nav-bar
        title="挂单"
        left-arrow
        @click-left="xy"
        fixed
    />

    <div style="margin-top: 50px">
      <span style="margin-left: -250px;margin-bottom: 10px;">挂单原因:</span>
      <div style="margin-top: 10px;margin-left: 30px">
        <van-field
            v-model="from.reason"
            rows="2"
            autosize
            type="textarea"
            maxlength="50"
            placeholder="请输入挂单原因"
            border:true
            :style="{ border: '1px solid #ccc',width: '85%'}"
            show-word-limit
        />
      </div>
    </div>

    <div style="margin-top: 100px">
      <van-button type="primary" @click="qr" style="background-color: #023af5;width: 75%;height: 40px;border-radius: 20px"
                  size="large">确认
      </van-button>
    </div>

  </div>

</template>

<script>
import {Toast} from "vant";

export default {
  name: "Workorderbjxqgd",
  data() {
    return {
      from: {}
    }
  },

  created() {

  },

  methods: {
    xy() {
      this.$router.push('/workorderbj')
    },

    qr() {
      this.from.code = this.$route.query.code;
      this.from.state = 2;
      this.axios.post(`http://localhost:9999/api-cleaning-service/state/add`, this.from).then(res => {
        if (res.data.code == 1) {
          this.axios.post(`http://localhost:9999/api-cleaning-service/Workorder/limitupdate?code=`+this.from.code).then(res => {
            if (res.data.code == 1) {
              Toast.success("处理成功");
              this.$router.push('/workorderbj');
            }else{
              Toast.fail("处理失败");
            }
          })
        }
      })
    }



  }
}
</script>

<style scoped>

</style>